<template>
  <div class="schedule">
    <div>
      <el-button type="primary" @click="goNewSchedule">新建日程</el-button>
      <el-button v-if="!showUnfold" @click="showUnfold=true">展开筛选</el-button>
      <el-button v-if="showUnfold" type="info" @click="showUnfold=false">收起筛选</el-button>
    </div>
    <el-collapse-transition>
      <div v-if="showUnfold">
        <div class="search-box">
          <div class="search-list">
            <el-select v-model="searchList.course" placeholder="请选择课程" class="search-item">
              <el-option
                v-for="item in courseOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.courseKnob" placeholder="请选择课节" class="search-item">
              <el-option
                v-for="item in courseKnobOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.class" placeholder="请选择班级" class="search-item">
              <el-option
                v-for="item in classOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.campus" placeholder="请选择校区" class="search-item">
              <el-option
                v-for="item in campusOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <el-button type="primary">搜索</el-button>
        </div>
        <div class="search-box">
          <div class="search-list">
            <el-select v-model="searchList.classRoom" placeholder="请选择教室" class="search-item">
              <el-option
                v-for="item in classRoomOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.teacher" placeholder="请选择教师" class="search-item">
              <el-option
                v-for="item in teacherOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.appoint" placeholder="请选择预约规则" class="search-item">
              <el-option
                v-for="item in appointOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="search-list">
            <el-select v-model="searchList.schedule" placeholder="请选择日程状态" class="search-item">
              <el-option
                v-for="item in scheduleOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </div>
        </div>
      </div>
    </el-collapse-transition>
    <el-table :data="scheduleForm" border style="margin-top:20px;">
      <el-table-column label="上课时间" prop="classTime" align="center" />
      <el-table-column label="课程" prop="course" align="center" />
      <el-table-column label="班级" prop="class" align="center" />
      <el-table-column label="课节" prop="courseKnob" align="center" />
      <el-table-column label="老师" prop="teacher" align="center" />
      <el-table-column label="校区" prop="campus" align="center" />
      <el-table-column label="教师" prop="classRoom" align="center" />
      <el-table-column label="预约规则" prop="appoint" align="center" />

      <el-table-column label="已约/可约人数" prop="client" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.yetAppoint }}</span>
          <span>/</span>
          <span>{{ scope.row.maxAppoint }}</span>
        </template>
      </el-table-column>
      <el-table-column label="到课/应到人数" prop="client" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.nowInClass }}</span>
          <span>/</span>
          <span>{{ scope.row.shouldInClass }}</span>
        </template>
      </el-table-column>

      <el-table-column label="日程状态" prop="schedule" align="center" />
      <el-table-column label="操作" fixed="right" align="center" width="200">
        <template slot-scope="scope">
          <el-button type="text" @click="goScheduleInfo">日程详情</el-button>
          <el-button type="text" @click="goNewSchedule">编辑</el-button>
          <el-button type="text">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showUnfold: false,
      searchList: {
        course: '',
        courseKnob: '',
        class: '',
        campus: '',
        classRoom: '',
        teacher: '',
        appoint: '',
        schedule: ''
      },
      courseOptions: [],
      courseKnobOptions: [],
      classOptions: [],
      campusOptions: [],
      classRoomOptions: [],
      teacherOptions: [],
      appointOptions: [
        {
          value: '需预约',
          label: '需预约'
        },
        {
          value: '无需预约',
          label: '无需预约'
        }
      ],
      scheduleOptions: [
        {
          value: '未授课',
          label: '未授课'
        },
        {
          value: '授课中',
          label: '授课中'
        },
        {
          value: '已授课',
          label: '已授课'
        }
      ],
      scheduleForm: [
        {
          classTime: '2019-06-03',
          course: '语文作文',
          class: '提升班',
          courseKnob: '第一节',
          teacher: '王雯',
          campus: '校本部',
          classRoom: '速成教室',
          appoint: '需预约',
          yetAppoint: '12',
          maxAppoint: '100',
          nowInClass: '49',
          shouldInClass: '50',
          schedule: '授课中'
        }
      ]
    }
  },
  methods: {
    goScheduleInfo() {
      this.$router.push({ name: 'Scheduleinfo' })
    },
    goNewSchedule() {
      this.$router.push({ name: 'Newschedule' })
    }
  },
}
</script>

<style lang="scss" scoped>
.schedule {
  .search-box {
    margin: 20px 0;
    display: flex;
    .search-list {
      margin-right: 20px;
      color: #353535;
      .search-item {
        width: 280px;
      }
    }
  }
}
</style>
